// pages/bargainInfo/bargainInfo.js

//获取app实例
const app = getApp();
var utils = require("../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    infoList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中',
      mask: true
    });
    wx.request({
      url: app.baseURL + 'Bargain&a=help_detail&bar_id=' + options.bar_id,
      success: (res) => {
        const data = res.data;
        // 时间戳转换
        data.help_info.forEach(item => item.addTime = utils.formatTime(item.add_time * 1000));
        // 赋值
        this.setData({
          totalPrice: data.total_price,
          infoList: data.help_info
        });
        wx.hideLoading();
      },
      fail: err => {
        wx.hideLoading();
        wx.showToast({
          title: '网络错误，请稍后重试'
        })
      },
    })
  }
})